XTEND/CMD, written by Rik Karlsson, November, 1985.

This program is intended for Model 4/4P users who want to experiment with an extended BASIC ROM language.  However, Model III hackers should download XTEND/SRC (EDTASM format) and review the code for the various functions.  Each one could be configured as a USR file.

First, let's look at some background to the writing of this program.  Ever since the Model I got into the hands of hackers, there were cries for changes to BASIC to enhance its capabilities.  Extended BASICs were introduced almost immediately.  Model-I Level I cassette BASIC was improved with the Level II upgrade.  I'm probably not the only one who marveled at the L-II 16K Model I as the epitome of personal computing!

In 1979, GRT Corporation put out G2 Level III BASIC which added Disk level functions plus many unique BASIC enhancements to Level II cassette systems.  Disk BASIC extended BASIC further.  Racet Computes of Orange, California brought out GSF (Generalized Subroutine Facility) in 1978 and then Infinite BASIC in 1979.  While G2 'hooked' into ROM BASIC by using the RAM links to disk BASIC, Racet's additions were put into memory and called as complex USR routines.  Lewis Rosenfelder's book 'BASIC Faster and Better' in 1981 codified the USR approach with a whole raft of routines that the average user could put into his own BASIC programs to achieve all sorts of fancy tricks.

But, there still was always that lingering feeling among many, I'm sure, that if only they could get at that locked up ROM, why they'd tune it just the way they wanted it so that in the memory starved 8-bit world of the Z-80 machines, more could be accomplished with less fuss, bother and memory loss to added routines.

Until the Model 4P came along, RS continued to build BASIC into ROM.  But, the 4P was a RAM only machine! Aha! These guys required you to load a ROM image (IMAGE!) to RAM to operate in Model III mode.  And, yes, when one had a large library of Model I/III programs that had become old friends, it was not unlikely that the new machine would get a lot of use in the Model III mode.  Besides, the type size was larger on the small screen and for most applications the 64 character line screen was just fine.  Besides, the screen was memory mapped so that it was really easy for the average hacker to get to it without esoteric CALLs to the DOS.

But here was the perfect opportunity to muck around in the ROM area.  And that is what this program is all about.  It is an overlay and modifier of the MODELA/III BASIC to add some neat functions that can be programed as easily as any other BASIC reserved words.

Here is a brief explanation of the program.  Remember, this is ONLY for the Model 4/4P operating in the Model III ROM image mode. (Or for the Model I/III if reprogrammed as USR routines.)

This program extends ROM image BASIC to include three new BASIC commands that can be called either in direct or program mode:

     SOUND(TONE,DURATION) - For Model III, must use cassette
     port per Bill Barden in 'TRS-80 Assembly Language
     Subroutines,' Prentice-Hall 1982.

     SWAP(VAR,VAR) or SWAP(VAR=VAR)

     SCROLL(LINE,LINE) or
     SCROLL@(SCREEN POS,SCREEN POS) or
     SCROLL@(SCREEN POS,SCREEN POS,CHARACTER)

SOUND: Allows any value of tone and duration to be input.  The
       sound can be interrupted by pressing the <BREAK> key
       if a very long value is inadvertantly placed into the
       variables.

SWAP: Allows the values of numeric variables to be switched
      one to the other and vice versa.  Allows string variable
      VARPTR values to be switched avoiding clobbering memory
      with strings when swapping values. Also allows a
      variable or string VARPTR to be set equal to another.
      This is primarily useful for strings.

SCROLL: In the form SCROLL(LINE#,LINE#) allows partial screen
        scrolling only on the lines selected, e.g. SCROLL(1,5)
        will scroll lines 2 to 5 up one line and blank out
        line 5.  This routine leaves the cursor pointing to
        the start of the vacated (blanked) line so that the
        next print statement will automatically print on that
        line.

        In the form SCROLL@(SCREEN POS,SCREEN POS) allows
        partial screen scroll but only between the two screen
        positions (0 TO 1023) selected.

        In the form SCROLL@(SCREEN POS,SCREEN POS,CHAR)
        allows a block to be drawn on the screen defined by
        the upper left, lower right and character to be put to
        the screen. The character can be any legal ASCII or
        graphics character defined as a literal or string
        value.

How was all this accomplished?  Well, this program zeroes out areas no longer needed in the ROM image because the 4P does not have cassette input, and replaces them with new code that adds three new reserved words and six new functions; SWAP, SCROLL, and SOUND.

SCROLL functions in two different modes.  First: SCROLL(1,15) where the values are screen lines to scroll between.  If the first number is less than the second, the scroll will be up one line using the lines designated. The cursor is left pointing to the last line moved, which is cleared prior to returning to BASIC.

Second, the SCROLL@(POS,POS(,CHR)) routine which will do three mutually exclusive functions depending on how it is called.

FIRST: SCROLL@(0,1023) will scroll the portion inside the box described by the upper left corner, lower right corner up one line.

SECOND: SCROLL@(1023,0) will scroll the portion inside the box down one line.

The relationship between the position parameters is checked and if the first is less than the second, then scroll up one line, and if the first is greater than the second, scroll down one line.

THIRD: SCROLL@(10,200,32) or SCROLL@(10,200,"X") or SCROLL@(10,200,CHR$(140)) will put the character defined by the third value into every screen position in the boX defined by the first two values.  In this case, the first two values can be in any order to make it work properly.

The call SCROLL@(10,200,32) will essentially CLS the box defined by 10,200. This is be especially useful if a particular screen area defined by 10,200 is used as a "window" for a menu or partial menu and then it was desired to change the window completely rather than just scroll it up or down.

In the first two cases, after the scroll is completed, the cursor is left at the position of the next logical 'PRINT' to CRT, that is, the last line from which data is moved.  When scroll "up" is invoked, the cursor would end the routine pointing to the start of the last line scrolled up, or the top line of the box if scroll down is invoked. When the form SCROLL@(10,200,32) is used, the cursor is left pointing to the top line of the box in every case.

SWAP routine:
     Syntax as follows:
          SWAP(VARIABLE NAME,VARIABLE NAME) reverses variable
          meanings.
          SWAP(VARIABLE=VARIABLE) sets first named equal to
          second particularly attractive for strings to avoid
          clobbering string area.
          SWAP(GET SCREEN# @ POSITION) causes screen swap to
          take place from present screen to alternate screen.
          The '@ POSITION' is optional, but if used sets the
          cursor position for next print to the screen
          position called for.

If you have questions about this program, address them to me on Andrus', Tech-Connect, Handy Tandy or NCTCUG BBS or on Compuserve (70140,404) or GEnie (Email address: CAPT.RIK).

January 17, 1987
                                                                                                                   